<include file="public/layout" />
 
<style type="text/css">
html, body {
	overflow: visible;
}
</style>  
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
  <div class="fixed-bar">
    <div class="item-title"><a class="back" href="{:U('/Admin/Order/return_list')}" title="微信公众号配置"><i class="fa fa-arrow-circle-o-left"></i></a>
      <div class="subject">
        <h3>退换货详情</h3>
        <h5>用户提交退换货详情</h5>
      </div>
    </div>
  </div>
  <form class="form-horizontal" method="post" id="return_form"  name="return_form" action="{:U('Admin/Order/return_info')}">    
    <div class="ncap-form-default">
      <dl class="row">
        <dt class="tit">
          <label>订单编号</label>
        </dt>
        <dd class="opt">
           <a href="{:U('Admin/order/detail',array('order_id'=>$return_goods['order_id']))}">{$return_goods.order_sn}</a>
        </dd>
      </dl>
      <dl class="row">
        <dt class="tit">
          <label for="cate_id">用户</label>
        </dt>
        <dd class="opt">
         {$user.nickname}
        </dd>
      </dl>    
	  <dl class="row">
        <dt class="tit">
          <label>申请日期</label> 
        </dt>
        <dd class="opt">
          {$return_goods.addtime|date="Y-m-d H:i",###}
        </dd>
      </dl>        
	  <dl class="row">
        <dt class="tit">
          <label >商品名称</label>
        </dt>
        <dd class="opt">
           <a href="{:U('Home/Goods/goodsInfo',array('id'=>$return_goods[goods_id]))}" target="_blank">{$goods[goods_name]}</a>
        </dd>
      </dl>   
      <dl class="row">
        <dt class="tit">
          <label>退换货</label> 
        </dt>
        <dd class="opt">
          <select  name="type" id="return_type" class="form-control">
               <option value="0" <if condition="$return_goods['type'] eq 0">selected="selected"</if>>退货</option>
               <option value="1" <if condition="$return_goods['type'] eq 1">selected="selected"</if>>换货</option>
          </select>
          <span id="tuikuan">
	          <input  type="text" placeholder="请输入退款金额" id="back_money" value="{$pay_info['total_fee']/100}"/>
<!-- 	          <a class="ncap-btn ncap-btn-green"  href="{:U('Admin/user/account_edit',array('id'=>$return_goods[user_id],'user_money'=>$goods[shop_price],'desc'=>'退货退款到余额'))}">原路退款</a> -->
          	  <a class="ncap-btn ncap-btn-green" id="return_money" href="javascript:void(0)">原路退款</a>
          	  <lable>此单可退金额:{$pay_info['total_fee']/100}</lable>
          </span>
        </dd>
      </dl>
      <dl class="row">
        <dt class="tit">
          <label>退货描述</label> 
        </dt>
        <dd class="opt">
          <textarea name="reason" id="reason" style="width:400px; height:120px;"  placeholder="退货描述" class="tarea" id="subject_desc">{$return_goods['reason']}</textarea>
        </dd>
      </dl>
      <dl class="row">
        <dt class="tit">
          <label>用户上传照片</label> 
        </dt>
        <dd class="opt">
          <volist name="return_goods[imgs]" id="item">  
	           <a href="{$item}" target="_blank"><img src="{$item}" width="85" height="85" /></a>&nbsp;&nbsp;&nbsp;                            
	       </volist>
        </dd>
      </dl>
      <dl class="row">
        <dt class="tit">
          <label>状态</label> 
        </dt>
        <dd class="opt">
          <select name="status">
               <option value="0" <if condition="$return_goods['status'] eq 0">selected="selected"</if>>未处理</option>
               <option value="1" <if condition="$return_goods['status'] eq 1">selected="selected"</if>>处理中</option>
               <option value="2" <if condition="$return_goods['status'] eq 2">selected="selected"</if>>已完成</option>                                             
          </select>
        </dd>
      </dl>
      <dl class="row">
        <dt class="tit">
          <label>处理备注</label> 
        </dt>
        <dd class="opt">
          <textarea name="remark" id="remark" style="width:400px; height:120px;"  placeholder="退货描述" class="tarea" id="subject_desc">{$return_goods['remark']}</textarea>
        </dd>
      </dl>
      <input type="hidden" name="id" value="{$id}">
      <div class="bot"><a href="JavaScript:void(0);" onClick="document.return_form.submit()" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
    </div>
  </form>
</div>
<script type="text/javascript">
    $(function(){
    	$("#return_type").change(function(){
    		if($(this).val() == 0){
    			$("#tuikuan").css("display","inline");
    		}else{
    			$("#tuikuan").css("display","none");
    		}
    	});
    	
    	$("#return_money").click(function(){
    		var back_money = $("#back_money").val();
    		var total_money = {$pay_info['total_fee']|default=0};
    		var order_sn = {$return_goods.order_sn};
    		var user_id = {$user.user_id};
    		if(back_money > total_money/100){
    			layer.alert("退款金额大于支付金额");
    		}else{
    			$.ajax({
					type:"POST",
					url:"/admin/order/WX_refund",
					data:{"back_money":back_money,"order_sn":order_sn,"user_id":user_id},
					dataType:"json",
					async:false,//同步操作
					success:function(data){
						layer.alert(data.msg);
						if(data.status == 1){
							$("#return_money").css("pointer-events","none");
							$("#return_money").text("已退款");
							$("#back_money").attr("disabled","disabled");
						}
					}
				});
    		}
    	});
    });
</script>
</body>
</html>